import http from "../utils/http";
import type {LiveTab,LivingList,GuessLikeData, ShoppingMallNav,ProductCoupon,SearchKeyWordData, HomeTitle, HomeVideo, VideoViewPic, CommentData, HotSearchData } from '@/typings'

export const Api = {


    // 获取主页title、
    getHomeTitle: () => {
        return http.get<Array<HomeTitle>>(`homeNav.json`)
    },

    // 获取主页商品信息
    getHomeVideo: () => {
        return http.get<HomeVideo>(`video/item?page=1`)
    },
    getVideoViewPic: (itemId: number, actorId: number) => {
        return http.get<VideoViewPic>(`video/detail?itemId=${itemId}&actorId=${actorId}`)
    },
    // 获取视频的评论
    getVideoComments: (itemId: string, actorId: string, page: number) => {
        return http.get<CommentData>(`video/comment?itemId=${itemId}&actorId=${actorId}&page=${page}`)
    },

    // 热门搜索
    getHotSearchList: () => {
        return http.get<HotSearchData>('hotSearch.json')
    },

    // 输入关键字搜索:
    getSearchList: (kw: string,
        page:number=1,
        sort:string='pop',
        minPrice:number=0,
        maxPrice:number=1000,   
        offset:number=30
        ) => {
            console.log(sort);
            console.log(minPrice);
            console.log(maxPrice);
            console.log(page);
            
            
        return http.get<SearchKeyWordData>(`search/searchByKeyword?fcid=20005531&q=${kw}&page=${page}&sort=${sort}&minPrice=${minPrice}&maxPrice=${maxPrice}&offset=${offset}`)
    },

    // 商品主页
    getProductDetailList:(itemId:string)=>{
        return http.get(`goods/detail?itemId=${itemId}`)
    },

    // 商品优惠券
     getProductCoupon:(itemId:string)=>{
          return http.get<ProductCoupon>(`goods/getPromotionList?itemId=${itemId}`)
     },

     getShoppingMallNav:()=>{
        return http.get<Array<ShoppingMallNav>>(`shopNav.json`)
     },
    //   猜你喜欢
     getGuessLikeData:()=>{
        return http.get<GuessLikeData>(`goods/personalized?page=2`)
     },

    //  直播tab
    getLiveTab:()=>{
        return http.get<LiveTab>(`live/tabHeader`)
    },

    // 直播列表
    getLivingList:(tabId:number,pageIndex:number)=>{
     return http.get(`live/tabList?tabId=${tabId}&pageIndex=${pageIndex}`)
    }

}